<template>
  <van-nav-bar :title="type=='history'?'浏览历史':'我的收藏'" left-text="返回" left-arrow @click-left="router.back()" :fixed="true" />
    <div class="history">
      <van-tabs v-model:active="active" @click-tab="onClickTab" sticky>
        <van-tab title="宠物">
          <InfoCardList isEdit :list="type=='collection'?user.mycollectionList:user.myhistoryList" />
        </van-tab>
        <van-tab title="分享">
          <div class="list" v-if="user.shareList.length > 0">
            <concernItem isEdit v-for="(item) in type=='collection'?user.mycollectionList:user.myhistoryList" :item="item" :key="item.shareposts_id"></concernItem>
          </div>
        </van-tab>
      </van-tabs>
    </div>
</template>

<script setup lang='ts'>
import InfoCardList from '@/components/InfoCardList.vue';
import concernItem from '@/components/concernItem.vue';
import router from '@/router';
import { userStore } from '@/store/index';
import { onMounted } from 'vue';
import {actions} from '@/common/commonMap'
const user = userStore()
const active=0
let type: string = router.currentRoute.value.params.type as string
const onClickTab = (e:any) => {
  if (type === 'collection') {
    user.queryMycollectionListByType(actions[e.name].type)
  }else{
    user.queryMyhistoryListByType(actions[e.name].type)
  }
}
onMounted(()=>{
  if (type === 'collection') {
    user.queryMycollectionListByType(actions[active].type)
  }else{
    user.queryMyhistoryListByType(actions[active].type)
  }
  console.log(user.mycollectionList);
  
})
</script>

<style lang='less' scoped>
.history {
    width: 100%;
    position: absolute;
    top: 3rem;
  }
</style>
